﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NutriFast
{
    public partial class DietaFin : Form
    {
        int current;
        static int nMeal = 10;
        static int nRes = 6;
        public static Label[] C = new Label[nMeal];
        public static Label[,]R=new Label[nMeal,nRes];
        public DietaFin(int cur,int nMeals)
        {
            current = cur;
            nMeal = nMeals;
            InitializeComponent();
            lblnC.Text=""+nMeals;
            lblidPac.Text = "P00" + cur;
            lblNom.Text = dbTavo.searchP(cur);
            lblidD.Text = "DI0"+dbVic.buscarDieta();
            string[] ddie = new string[4];
            ddie = dbTavo.searchDiet(dbVic.buscarDieta());
            lclPes.Text = ddie[0]+" kg.";
            lblpt.Text = ddie[1];
            lbllip.Text = ddie[2];
            lblcho.Text = ddie[3];

            lblDate.Text = DateTime.Today.DayOfWeek+"    "+DateTime.Today.Day+" / "+DateTime.Today.Month+" / "+DateTime.Today.Year;

            int n = 0;
            for (int i = 0; i < nMeal; i++)
            {
                ///////////Botones
                C[i] = new Label();
                C[i].Text = "Comida " + (i + 1);
                C[i].Name = "" + (i + 1);
                C[i].Size = new Size(580, 40);
                C[i].Font = new System.Drawing.Font("Microsoft Sans Serif", 20F);
                C[i].BackColor = System.Drawing.SystemColors.Highlight;
                C[i].Location = new Point(0, (n *20));
                panel3.Controls.Add(C[i]);
                n = n + 2;
                for (int j = 0; j < nRes; j++)
                {
                    System.Console.WriteLine(n);
                    R[i, j] = new Label();
                    R[i, j].Text = "    -    Enchiladas " + (j+1);
                    R[i, j].Name = "" + n;
                    R[i, j].Size = new Size(570, 20);
                    R[i, j].Font = new System.Drawing.Font("Microsoft Sans Serif", 10F);
                    if(j%2>0)
                        R[i, j].BackColor = System.Drawing.SystemColors.ControlDark;
                    else
                        R[i, j].BackColor = System.Drawing.SystemColors.ControlLight;
                    R[i, j].Location = new Point(0, (n * 20));
                    panel3.Controls.Add(R[i,j]);
                    n++;
                }
                
            }
        }

        private void DietaFin_Load(object sender, EventArgs e)
        {
            try
            {
                string filename = "C:../../Fotos/" + current + ".jpg";
                pictureBox1.Image = new Bitmap(filename);
            }
            catch (Exception)
            {
                pictureBox1.Image = NutriFast.Properties.Resources.defaultUser;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Historial his = new Historial(current,float.Parse(lblcho.Text),float.Parse(lbllip.Text),float.Parse(lblpt.Text));
            his.name.Text = this.lblNom.Text;
            his.MdiParent = this.MdiParent;
            his.Show();
        }
    }
}
